package com.binguo.api.controller;


import com.binguo.api.result.Result;
import com.binguo.api.result.ResultGenerator;

import com.binguo.model.model.Branch;
import com.binguo.model.repository.BranchRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Condition;


import java.util.List;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
 * @author yuritian
 * @Title: BranchController
 * @ProjectName binguoDevelop
 * @Description: TODO
 * @date 2019-12-1810:57
 */
@Api(tags = "分店绑定")
@RestController
@RequestMapping
public class BranchController {

    @Autowired
    BranchRepository branchRepository;

    @GetMapping(value = "/api/branch/list/{shopId}", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取分店列表")
    public Result getOrders(@PathVariable Integer shopId){

        Condition condition = new Condition(Branch.class);
        condition.or().andEqualTo("shopId",shopId);

        List<Branch> branchList = branchRepository.findByCondition(condition);

        return ResultGenerator.genSuccessResult(branchList);
    }

}
